Skip to content

Fix #14684: FP unreadVariable with auto and brace-init#8508

Open
ludviggunne wants to merge 2 commits intocppcheck-opensource:mainfrom
ludviggunne:14684
Open

Fix #14684: FP unreadVariable with auto and brace-init#8508
ludviggunne wants to merge 2 commits intocppcheck-opensource:mainfrom
ludviggunne:14684

Conversation

@ludviggunne
Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread test/testunusedvar.cpp
Comment thread lib/checkunusedvar.cpp Outdated
@ludviggunne ludviggunne marked this pull request as draft April 28, 2026 12:41
@ludviggunne ludviggunne marked this pull request as ready for review April 29, 2026 06:52
Comment thread lib/symboldatabase.cpp
if (!parent->astOperand1())
return;

if (Token::Match(parent->astOperand1()->previous(), "auto %var% {")) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could be variations like auto&& or auto const&.
Is the ValueType set correctly for e.g. T t{ 1 }?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the T from a template? I would assume it would be set to whatever it is in the instantiation, but i can double check.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the T from a template? I would assume it would be set to whatever it is in the instantiation, but i can double check.

I was thinking about e.g. struct T { int i; };. If that works, we might find a way to make auto work as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants